package com.wang;

import org.springframework.context.PayloadApplicationEvent;
import org.springframework.context.event.ApplicationEventMulticaster;
import org.springframework.context.event.SimpleApplicationEventMulticaster;

/**
 * Created by wlyfree on 2019/9/1.
 */
public class SpringEventTest {

    public static void main(String[] args) {
        ApplicationEventMulticaster multicaster = new SimpleApplicationEventMulticaster();
        multicaster.addApplicationListener(event -> {
            System.out.println("收到事件，事件类：" + event.getClass().getSimpleName() + "，事件内容：" + event.getSource());
        });
        multicaster.multicastEvent(new PayloadApplicationEvent<Object>("1", "hello"));
        multicaster.multicastEvent(new PayloadApplicationEvent<Object>("2", "hi"));
    }
}
